/*
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 *
 * Copyright @2008 the original author or authors.
 */
package com.bluestone.core;


/**
 * Element is the operator object of the action.
 * @author <a href="mailto:bluestone.daniel.q@gmail.com">daniel.q</a>
 */
public class Element {
	private Object parent;

	private String type;

	private String name;

	private int x = -1;

	private int y = -1;

	private int index = -1;
	
	private String  forward = null;
	

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	@Override
	public String toString() {
		String str = "element:";
		if (name != null) {
			str = str + "" + name;
		}
		if (type != null) {
			str = str + ",type=" + type;
		}
		if (x >= 0) {
			str = str + ",x=" + x;
		}
		if (y >= 0l) {
			str = str + ",y=" + y;
		}
		if (index >= 0l) {
			str = str + ",index=" + index;
		}		

		return (str);

	}

	public Object getParent() {
		return parent;
	}

	public void setParent(Object parent) {
		this.parent = parent;
	}

	/**
	 * The search path defines the element path.
	 * @return path - String
	 */
	public String getSearchPath() {
		String path = "";
		if (parent != null) {
			path = ((Page) parent).getSearchPath();
		}
		path = path + "|" + name;
		return path;
	}

	/**
	 * The index defines the movement count of the tab key form header. 
	 * @return index - int
	 */
	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	/**
	 * The page path(s) which the element need to find.
	 * @return forward - String
	 */
	public String getForward() {
		return forward;
	}

	public void setForward(String forward) {
		this.forward = forward;
	}
}
